﻿using DAO;
using AutomationView.Views;
using System;
using System.Collections.Generic;
using System.Text;

namespace AutomationView
{
    class SimpleFactory
    {
        static SimpleFactory()
        {
            StructureMap.ObjectFactory.Configure(x =>
            {
                x.For<CustomersEngine>().ConditionallyUse(c =>
                {
                    //c.If(ctx => System.Configuration.ConfigurationManager.AppSettings["console"] == "True")
                    //    .ThenIt.Is.ConstructedBy(_ => new FormCustomersEngine());
                    c.TheDefault.Is.ConstructedBy(_ => new FormCustomersEngine());
                });

                x.For<AddCustomerEngine>().Use<FormAddCustomerEngine>();
                x.For<DAO.ICustomerDao>().Use<Models.CustomerDao>();

                x.For<AddCustomerEngineView>().Use<AddCustomerEngineView>();
                x.For<CustomersEngineView>().Use<CustomersEngineView>();
            });
        }

        public static T GetObject<T>()
        {
            return StructureMap.ObjectFactory.GetInstance<T>();
        }
    }
}
